import { createStore, applyMiddleware } from 'redux'
import thunkMiddleware from 'redux-thunk'
import { createLogger } from 'redux-logger'
import rootReducer from './reducers'

let middlewares = [thunkMiddleware];
if (process.env.NODE_ENV === 'development') {
    middlewares.push(createLogger());
}

function configStore () {
  const store = createStore(rootReducer, applyMiddleware(...middlewares))
  return store
}

const store = configStore();

export {store}
